#include<iostream>
#include<string>
#include<set>
using namespace std;
int n;
string s;
set<int>S;
int main()
{
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		int k = s[i] - 'A' + 1;
		S.insert(k);
		if (S.size() == 3) {
			ans = i + 1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}